function ret = isOnDate(event, today)
    ret = 0;
    
    checkRepeatStop = 1;
    
    start = event.start;
    stop  = event.stop;
    delta = stop - start;
    
    switch lower(event.repeat.type)
        case 'none'
            checkRepeatStop = 0;
            if today >= start && today <= stop
                ret = 1;
            end
        case 'weekly'
            startweek = start;
            switch lower(datestr(start, 'ddd'))
                case 'mon'
                    startweek = start - 1;
                case 'tue'
                    startweek = start - 2;
                case 'wed'
                    startweek = start - 3;
                case 'thu'
                    startweek = start - 4;
                case 'fri'
                    startweek = start - 5;
                case 'sat'
                    startweek = start - 6;
            end
            todayweek = today;
            switch lower(datestr(today, 'ddd'))
                case 'mon'
                    todayweek = today - 1;
                case 'tue'
                    todayweek = today - 2;
                case 'wed'
                    todayweek = today - 3;
                case 'thu'
                    todayweek = today - 4;
                case 'fri'
                    todayweek = today - 5;
                case 'sat'
                    todayweek = today - 6;
            end
            
            weekdiff = ceil((todayweek - startweek) / 7);
            
            skipweek = event.repeat.skipweek;
            if mod(weekdiff, skipweek) == 0
                
                day = lower(datestr(today, 'ddd'));
                for i = 1:size(event.repeat.weekdays, 2)
                    daynum = 0;
                    switch lower(event.repeat.weekdays{i})
                        case 'sun'
                            daynum = 1;
                        case 'mon'
                            daynum = 2;
                        case 'tue'
                            daynum = 3;
                        case 'wed'
                            daynum = 4;
                        case 'thu'
                            daynum = 5;
                        case 'fri'
                            daynum = 6;
                        case 'sat'
                            daynum = 7;
                    end

                    goodday = todayweek + daynum - 1;
                    dayDelta = today - goodday;

                    if dayDelta >= 0 && dayDelta <= delta
                        ret = 1;
                    end
                end
            end  
            
        case 'monthly'
            startvec   = datevec(start);
            startyear  = startvec(1);
            startmonth = startvec(2);
            startday   = startvec(3);
            
            todayvec   = datevec(today);
            todayyear  = todayvec(1);
            todaymonth = todayvec(2);
            todayday   = todayvec(3);

            currmonth = todaymonth;
            if currmonth < startmonth
                currmonth = currmonth + 12;
            end
                        
            dayDelta   = datenum(startyear, startmonth, todayday) - datenum(startyear, startmonth, startday);
            skipmonth   = event.repeat.skipmonth + 1;
            if dayDelta >= 0 && dayDelta <= delta
                monthdiff = currmonth - startmonth;
                if mod(monthdiff, skipmonth) == 0
                    ret = 1;
                end
            end
            
        case 'date'
            startvec   = datevec(start);
            startyear  = startvec(1);
            startmonth = startvec(2);
            startday   = startvec(3);
            
            todayvec   = datevec(today);
            todayyear  = todayvec(1);
            todaymonth = todayvec(2);
            todayday   = todayvec(3);
            
            dayDelta   = datenum(startyear, todaymonth, todayday) - datenum(startyear, startmonth, startday);

            skipyear   = event.repeat.skipyear + 1;

            if dayDelta >= 0 && dayDelta <= delta
                yeardiff = todayyear - startyear;
                if mod(yeardiff, skipyear) == 0
                    ret = 1;
                end
            end
            
    end

    if today < start
        ret = 0;
    end
    
    if checkRepeatStop == 1 && ~isempty(event.repeat.stopdate)
        if event.repeat.stopdate ~= -1
            if today > event.repeat.stopdate
                ret = 0;
            end
        end
    end
    
end

